package com.wisco.web.demo.action;
import java.io.IOException;
import java.io.PrintWriter;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.apache.struts2.convention.annotation.Action;
import org.springframework.stereotype.Controller;
import com.wisco.plarform.action.PlatformAction;
import com.wisco.web.demo.model.User;
import com.wisco.web.demo.service.UserService;
@Controller
public class InformationAction extends PlatformAction {
	private static final long serialVersionUID = 1L;
	@Resource
	private UserService userService;
	String username;
	String password;
	String qq;
	String phone;
	String alipay;
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getQq() {
		return qq;
	}
	public void setQq(String qq) {
		this.qq = qq;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getAlipay() {
		return alipay;
	}
	public void setAlipay(String alipay) {
		this.alipay = alipay;
	}
	HttpSession session=this.getRequest().getSession();
	User sessionuser=(User)session.getAttribute("user");
	/*
	 * 完成个人信息接口
	 */
	@SuppressWarnings("unchecked")
	@Action(value = "/fillAccount")
	public void fillAccount() {
		User user = new User();
		user.setUserid(sessionuser.getUserid());
		user.setAlipay(alipay);
		user.setPassword(password);
		user.setQq(qq);
		user.setUsername(username);
		user.setPhone(phone);
		userService.completeinfo(user);
	}
	/*
	 * 找回密码接口
	 */
	@SuppressWarnings("unchecked")
	@Action(value = "/findPassword")
	public void FindPwd() {
		PrintWriter out = null;
		String 		pwd = null;
		try {
			out = (PrintWriter)this.getResponse().getWriter();
		} catch (IOException e) {
			e.printStackTrace();
		}
		 pwd = userService.findPwd(username, phone);
		 out.print("{}");
		 out.flush();
		 out.close();	
	}
	/*
	 * 获取个人信息接口
	 */
	@SuppressWarnings("unchecked")
	@Action(value = "/getinformation")
	public void Getinformation() {
		PrintWriter out = null;
		User user = new User();
		try {
			out = (PrintWriter)this.getResponse().getWriter();
		} catch (IOException e) {
			e.printStackTrace();
		}
		user = userService.findinformation(sessionuser.getUserid());
		out.print("{}");
		out.flush();
		out.close();	
	}
	@Override
	public Object getViewModel() {
		return null;
	}
}
